import 'package:demo202112/utils/common_appbar.dart';
import 'package:flutter/material.dart';

/// @Author wywinstonwy
/// @Date 2022/10/23 11:28
/// @Description: 

class StepTweenPage extends StatefulWidget {
  const StepTweenPage({Key? key}) : super(key: key);

  @override
  State<StepTweenPage> createState() => _StepTweenPageState();
}

class _StepTweenPageState extends State<StepTweenPage>with SingleTickerProviderStateMixin {
  late AnimationController controller;
  late Animation<int> stepAnim;
  int _stepNum = 10;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    controller = AnimationController(vsync: this,duration: Duration(seconds: _stepNum));
    controller.addListener(() {
      print("controller=====${controller.value}");
    });
    controller.addStatusListener((status) {
      print("status====$status");
    });
    
    stepAnim = StepTween(begin: _stepNum,end: 0).animate(controller)
    ..addListener(() {
      print("stepAnim====${stepAnim.value}");
      setState(() {
        this._stepNum = stepAnim.value;
      });
    })
    ..addStatusListener((status) { 
      
    });
    controller.forward();
  }
  @override
  void dispose() {
    // TODO: implement dispose
    controller.dispose();
    super.dispose();
  }
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: getAppBar("StemTween动画"),
      body: Column(children: [
        Text(stepAnim.value.toString(),style: TextStyle(fontSize: 150),)
      ],),
    );
  }
}
